<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="aa" uri="/WEB-INF/tld/ajaxanywhere.tld" %>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>jsp</title>
<script src="/webjars/jquery/3.5.1/jquery.js"></script>
<script src="/aa.js"></script>
	<script src="/resources/js/http.js"></script>
	<script src="/resources/js/vue.global.prod.js"></script>
	<script src="/resources/js/bootstrap.bundle.min.js"></script>
	<script src="/resources/js/feather.min.js"></script>
<link rel="stylesheet" href="/resources/css/bootstrap.min.css" />
<link rel="stylesheet" href="/resources/css/dashboard.css" />
</head>
<body>
	<h1>${msg}</h1>
<br />
 <button type="button" id="btQuery">查询列表</button>
 <aa:zone name="zoneJ">
  <ul>
   <c:forEach var="o" items="${list}" varStatus="s">
    <li>${s.count} , id: ${o.id} , name: ${o.name} ,createDate: ${createDate}</li>
   </c:forEach>
  </ul>
 </aa:zone>
 <hr />

	<div class="container">
		<div class="mb-3">
			<label  class="form-label">ID</label> 
			 <input type="text" class="form-control"  name="id" id="id">
		</div>
		<div class="mb-3">
			<label  class="form-label">NAME</label> 
			 <input type="text" class="form-control"  name="name"  id="name">
		</div>
		<button type="button" id="btSave" class="btn btn-success">保存</button>
		<button type="button" id="btDelete" class="btn btn-warning">删除</button>
		<button type="button" id="btSaveBatch" class="btn btn-warning">批量保存</button>
	</div>
 
 
</body>

<script type="text/javascript">
	$('#btQuery').click(function() {
		listPage(1)
	});

	function goPage(n) {
		listPage(n)
	}
	$('#btSave').click(function() {
	// 1. 获取数据
	let vo=getVo()
	//let vo=this.vo
	// 2.提交数据
	$http.post('/save/demo',vo).then(res=>{
		console.log(res)
	})
	});
	
	$('#btSaveBatch').click(function() {
	// 1. 获取数据
	//let vo=getVo()
	let data=[{}]
	// 2.提交数据
	$http.post('/save/demo',vo).then(res=>{
		console.log(res)
	})
	});
	
	
	
	function getVo(){
	    let vo={}
	    vo.id=$("#id").val();
	    vo.name=$("#name").val();
		return vo
	}
	
	$('#btDelete').click(function() {
	// 1. 获取数据
	let data=getDeleteData()
	//let vo=this.vo
	// 2.提交数据
	$http.post('/demo/deleteByIds',data).then(res=>{
		console.log(res)
	})
	});
	function getDeleteData(){
	let arr=[]
	arr.push('1')
	return arr
	}
	
	function listPage(pageNo){
		ajaxAnywhere.getAJAX('/j/list?pageSize=2&pageNo='+pageNo, 'zoneJ');
	}
	
	function getSaveDtoData(){
	
	
	}
	
</script>
</html>